import React, { Component } from 'react'

import MainBanner from './MainBanner'
import MainProductList from './MainProductList'

import axios from 'axios'

export class Main extends Component {
  constructor(props) {
    super(props)
    this.state = {
      banner: [],
      productList:[]
    }
  }
  componentDidMount() {
    axios.get('http://123.207.32.32:8000/home/multidata').then(res => {
      this.setState({
        banner: res.data.data.banner.list,
        productList: res.data.data.recommend.list
      })
    })
  }
  render() {
    const { banner, productList } = this.state
    return (
      <div>
        Main
        <br/>
        <MainBanner banner={banner} title='商品' />
        <MainProductList productList={productList} />
      </div>
    )
  }
}

export default Main